package com.wt.admin.service.ai.impl.agents;

import com.wt.admin.domain.dto.ai.AgentsInfoDTO;
import com.wt.admin.domain.entity.ai.MCPEntity;
import com.wt.admin.domain.entity.ai.ModelConfigEntity;
import com.wt.admin.service.ai.impl.agents.easyai.EasyAIChatModel;
import com.wt.admin.service.ai.impl.agents.easyai.api.EasyAIApi;
import com.wt.admin.service.ai.impl.agents.easyai.api.EasyAIOptions;
import io.micrometer.observation.ObservationRegistry;
import org.springframework.ai.model.tool.ToolCallingManager;
import org.springframework.ai.ollama.management.ModelManagementOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("EasyAI")
public class EasyAIBuilder extends AbstractAgentsBuilderService{

    @Value("${server.port}")
    private Integer port;


    @Override
    public AgentsManager.ChatClientMapper builder(AgentsInfoDTO agents, ModelConfigEntity model, List<MCPEntity> mcpEntities) {
        // 查询模型信息
        EasyAIOptions options = new EasyAIOptions();
        options.setModel(model.getModel());
        EasyAIApi easyAIApi = EasyAIApi.builder().baseUrl("http://localhost:"+port+"/qa").build();
        EasyAIChatModel easyAIModel = new EasyAIChatModel(easyAIApi,options,
                ToolCallingManager.builder().build(),
                ObservationRegistry.NOOP,
                ModelManagementOptions.defaults());
       return build(easyAIModel, agents, mcpEntities,options);
    }




}
